<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml" xmlns:shiro="http://www.w3.org/1999/xhtml">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
	<div class="wrapper wrapper-content ">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-content">
						<form class="form-horizontal m-t" id="signupForm">

<!--							<div th:text="${list}"></div>-->

							<input id="id" name="id" class="form-control" type="hidden">
							<input id="types" name="types" class="form-control" type="hidden">

<!--							<div class="form-group">-->
<!--								<label class="col-sm-3 control-label">考生编号：</label>-->
<!--								<div class="col-sm-8">-->
<!--									<input id="num2" name="num2" class="form-control" type="text">-->
<!--								</div>-->
<!--							</div>-->

							<div class="form-group">
								<label class="col-sm-3 control-label">考生姓名：</label>
								<div class="col-sm-8">
									<input id="name" name="name" class="form-control" type="text">
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-3 control-label">身份证号码：</label>
								<div class="col-sm-8">
									<input id="idNumber" name="idNumber" class="form-control" type="text">
								</div>
							</div>

<!--							<div class="form-group">-->
<!--								<label class="col-sm-3 control-label">认证批次id：</label>-->
<!--								<div class="col-sm-8">-->
<!--									<input id="cbatchId" name="cbatchId" class="form-control" type="text">-->
<!--								</div>-->
<!--							</div>-->

							<div class="form-group">
								<label class="col-sm-3 control-label">考号/手机号码：</label>
								<div class="col-sm-8">
									<input id="ticketNumber" name="ticketNumber" class="form-control" type="text">
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-3 control-label">单位名称：</label>
								<div class="col-sm-8">
									<input id="unitName" name="unitName" class="form-control" type="text">
								</div>
							</div>

							<div class="form-group">
								<label class="col-sm-3 control-label">指导老师：</label>
								<div class="col-sm-8">
									<input id="teacher" name="teacher" class="form-control" type="text">
								</div>
							</div>

							<div class="form-group" shiro:hasPermission="jzweb:stuSignUpCom:resetPwd">
								<label class="col-sm-3 control-label">赛场信息：</label>
								<div class="col-sm-8">
									<div class="form-control" id="race"></div>
<!--									<select class="form-control" name="court2" id="court2">-->
<!--										<option value="">请选择</option>-->
<!--										<option value="A1-C1">A1-C1</option>-->
<!--										<option value="A2-C2">A2-C2</option>-->
<!--										<option value="A3-C3">A3-C3</option>-->
<!--									</select>-->

<!--									<input id="court2" name="court2" type="text" class="form-control">-->
								</div>
							</div>

<!--							<div class="form-group" shiro:hasPermission="jzweb:stuSignUpCom:resetPwd">-->
<!--								<label class="col-sm-3 control-label"> 赛场录入：</label>-->
<!--								<div class="col-sm-8">-->
<!--									<input id="court2" name="court2" class="form-control" type="text">-->
<!--								</div>-->
<!--							</div>-->

							<div class="form-group" shiro:hasPermission="jzweb:stuSignUpCom:num1">
								<label class="col-sm-3 control-label"> 第一次加密：</label>
								<div class="col-sm-8">
									<input id="realityNm1" name="realityNm1" class="form-control" type="text">
								</div>
							</div>
<!--							-->
<!--							<div class="form-group" shiro:hasPermission="jzweb:stuSignUpCom:num2">-->
<!--								<label class="col-sm-3 control-label"> 第二次加密：</label>-->
<!--								<div class="col-sm-8">-->
<!--									<input id="realityNm2" name="realityNm2" class="form-control" type="text">-->
<!--								</div>-->
<!--							</div>-->

							<div class="form-group">
								<div class="col-sm-8 col-sm-offset-3">
									<button type="button" onclick="changeUpdate()" id="uploaDate" class="btn btn-primary">提交</button>
								</div>
							</div>

						</form>
					</div>
				</div>
			</div>
	</div>
	</div>
	<div th:include="include::footer"></div>
	<script src="//s.xlongwei.com/res/js/My97DatePicker/WdatePicker.js"></script>
<!--	<script type="text/javascript" src="/js/webJs/jzweb/stuSignUpCom/updateModule.js"></script>-->
	<script>

		let obj = JSON.parse(sessionStorage.getItem('obj'));
		if( obj ){
			$("#name").val( obj.name );
			$("#idNumber").val( obj.idNumber );
			$("#ticketNumber").val( obj.ticketNumber );
			$("#unitName").val( obj.unitName );
			$("#teacher").val( obj.teacher );
			$("#id").val(obj.id);
			// $("#court2").val(obj.court);
			$("#realityNm1").val(obj.num1);
			$("#realityNm2").val(obj.num2);
			$("#types").val(obj.types);
			// $("#cbatchId").val(obj.cbatchId);
			$("#race").html(obj.court)
		}

		$.ajax({
			cache : true,
			type : "get",
			url : "/jzApi/examinations/selExaminationComAll3",
			async : false,
			error : function(request) {
				parent.layer.alert("Connection error");
			},
			success : function(data) {

				if (data.code == 0) {

					$('#cbatchName').selectPage({
						showField: 'name',
						keyField: 'id',
						data: data.data,
						eAjaxSuccess : function(d){
							var result;
							if(d) result = d.data;
							else result = undefined;
							return result;
						},
						eSelect : function(data){
							$('#cbatchName').val(data.id);
						}
					});

				} else {
					parent.layer.alert(data.msg)
				}
			}
		});

		function changeUpdate() {
			// let id = $("#uploaDate").attr('data-id');

			if( !$("#name").val() ){
				layer.msg('请输入考生姓名');
				return false;
			}

			if( !$("#idNumber").val() ){
				layer.msg('请输入身份证号码');
				return false;
			}

			if( !$("#ticketNumber").val() ){
				layer.msg('请输入考号/手机号');
				return false;
			}

			if( !$("#unitName").val() ){
				layer.msg('请输入单位名称');
				return false;
			}

			$.ajax({
				cache : true,
				type : "POST",
				url : "/jzweb/stuSignUpComPo/updateEnter",
				data : $('#signupForm').serialize(),
				// data : {"id":id},
				async : false,
				error : function(request) {
					parent.layer.alert("Connection error");
				},
				success : function(data) {
					if (data.code == 0) {
						parent.layer.msg("操作成功");
						parent.reLoad();
						var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
						parent.layer.close(index);
					} else {
						parent.layer.alert(data.msg)
					}
				}
			});
		}

		$.ajax({
			cache : true,
			type : "POST",
			url : "/jzweb/examinationBatchCom/getBathComsByPid",
			data : {
				'pid': obj.cbatchId
			},
			// data : {"id":id},
			async : false,
			error : function(request) {
				parent.layer.alert("Connection error");
			},
			success : function(data) {
				if (data.code == 0) {
					let str = '';

					data.data.forEach(function (v,k){
						if( k == 0 ){
							str += `<option value="">请选择</option>`;
						}

						if( obj.court == v.name ){
							str += `<option value="${v.id}" selected>${v.name}</option>`;
						}else{
							str += `<option value="${v.id}">${v.name}</option>`;
						}

					})

					$("#court2").html(str)
				} else {
					parent.layer.alert(data.msg)
				}
			}
		});

	</script>
</body>
</html>
